﻿using System.Linq;
using MongoDB.Driver;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.Tests.Helpers
{
    public class GetMongoCollection<T>
    {
        public IMongoCollection<T> MongoCollection { get; private set; }
        public string CollectionName { get; private set; }

        public GetMongoCollection(string connectionString)
        {
            CollectionName = typeof(T).Name;
            var mongoClient = new MongoClient(connectionString);
            var database = mongoClient.GetDatabase(connectionString.Split('/').Last().Trim());

            MongoCollection = database.GetCollection<T>(CollectionName);
        }
    }
}
